package com.self.starter.use.controller;

import com.self.starter.pojo.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController(value = "/user")
public class SelfProsController {
    @Autowired(required = false)
    private UserClient userClient;

    @GetMapping("/user/name")
    public String getUserNmae() throws Exception {
        if(Objects.isNull(userClient)) {
            throw new Exception("请开启spring.self.props.enabled");
        }
        return userClient.getName();
    }
}
